﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SPPD.controller;
using SPPD.model;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Linq;
namespace SPPD
{
	/// <summary>
	/// Interaction logic for bendahara_sppd.xaml
	/// </summary>
	public partial class bendahara_sppd : Window
	{
        public List<sppd> list_sppd = new List<sppd>();
        public int select;
        public pegawai pegawaiLogin = new pegawai();
        public sppd edit = new sppd();
		public bendahara_sppd(pegawai pgawai)
		{
			this.InitializeComponent();
            pegawaiLogin = pgawai;
            controller_sppd dummy = new controller_sppd();
            
            list_sppd = dummy.load();
            for (int i = 0; i < list_sppd.Count; i++)
            {
                if (list_sppd[i].status > 1)
                {
                    list_sppd.RemoveAt(i);
                }
            }
            data.ItemsSource = list_sppd;
			// Insert code required on object creation below this point.
		}

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Window1 bendahara = new Window1(pegawaiLogin);
            this.Hide(); bendahara.Show();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Window4 tolak = new Window4(1, edit, pegawaiLogin);
            this.Hide(); tolak.Show();
        }

        private void data_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            select = data.SelectedIndex;
            edit = list_sppd[select];           
            
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            string id;
            id = list_sppd[select].id_sppd;
            controller_sppd dummy = new controller_sppd();
            dummy.update(edit);
           
        }
	}
}